<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<%@ page language="java" contentType="text/html;charset=utf-8"%>
<%@ include file="/pub/siteinclud.jsp"%>
<%
	String inforId = request.getParameter("inforId");
%>
<html>
<head>
<script charset="utf-8" src="/editor/kindeditor.js"></script>
<title>雅宝网 致力于服务雅宝路人的最大信息网</title>
<meta name="keywords" content="雅宝路 物流 交友 二手货 发货 甩货 免费发布信息" />
<meta name="description" content="雅宝路网，致力于服务雅宝路人的最大信息网。为你提供房产、车辆、招工、兼职、物流等海量雅宝路分类信息"/>
<script type="text/javascript"
	src="<%=path%>/resources/js/shouye.js"></script>
<link rel="stylesheet"
	href="<%=request.getContextPath()%>/site/${SiteAccessPath}/css/css.css"
	type="text/css"/>
<link rel="stylesheet"
	href="<%=request.getContextPath()%>/site/${SiteAccessPath}/css/global.css"
	type="text/css"/>
<script type="text/javascript">
	var codemap = new Array(); 
	$(function(){
        $.ajax({
			url :"<%=request.getContextPath()%>/ext/information/find/<%=inforId%>", //要访问的后台地址
		    data: "code=<%=com.wing.sys.domain.Code.YBL_TYPE_CODE%>", //要发送的数据
		    type : 'POST', //使用get方法访问后台
		    dataType : 'json', //返回json格式的数据
		    success : function(data){
	    		$("#title_div").html(data.title);
	    		$("#content_div").html(data.content);
	    		$("#name_time").html("发帖人："+data.sentName+"&nbsp;&nbsp;发表与："+(new Date(data.createtime)).format("yyyy-MM-dd hh:mm"));
	    		$("#type_id").val(data.type_id);
	    		$("#type_id2").val(data.type_id2);
	    		$("#eidt_editor_id").val(data.content);
	    		if("<%=(String)request.getSession().getAttribute((String)com.wing.common.Constants.SESSION_SITE_USER_ID)%>" ==data.creator ){
	    			$("#saveEditB1").show();
	    		}
	    		changeType(data.type_id2,"about_div");
		    }
		});	 
		loadGird("frmxxzs", 1);
		changeType("","other_div");
		
		$.formValidator.initConfig({formid:"informationform",alertmessage:false,onerror:function(msg){alert(msg)}});
		$("#editor_id").formValidator().inputValidator({min:10,onerror:"回复内容不得少于10个字符"}).inputValidator({max:10240,onerror:"回复内容超长"});
            
	})
		
	var callback_frmxxzs = function(rows, frm) {
       $.each(rows, function(i, n){
    	   var row = $("#"+frm+" .template").clone().removeClass("template");
   			       var keyValue = n.id;
	       row.find(".klfoor").html((i+2)+"楼");
	       row.find(".klcreator").html("回复人："+n.login_name);
	       row.find(".kltime").html("回复时间："+(new Date(n.createtime)).format("yyyy-MM-dd hh:mm"));
 		   row.attr("id","ready"+i);
           row.attr("class","tr_nbw");
           row.appendTo("#"+frm+" .grid");
           var c=n.content;
           if(n.status==<%=com.wing.ext.domain.Information.STATUS_DISABLE %>){
           	c="信息被屏蔽";
           }
           $("<tr>"+
	            "<td colspan='4' valign='top' align='left' class='font14' style='line-height:18px;'>"+c+"</td>"+
	         "</tr>").appendTo("#"+frm+" .grid");
	       $("<tr> <td height='10px'>&nbsp;</td> </tr>").appendTo("#"+frm+" .grid");
       });   
	}
	function save(){
		document.getElementById("editor_id").value=KE.html("editor_id");
		if($.formValidator.pageIsValid()){
			var options = {
				type: 'POST',
				async: false,
				success: function(msg) {
					if(msg=="codenull"){
						alert("验证码不得为空");
					}else if(msg=="failure"){
						alert("验证码不正确，请重新出入");
						$("veryCode").attr("value","");
					}else{
						alert("信息发布成功");
						document.location.reload();
					}
				}
			}
			$('#informationform').ajaxSubmit(options);
		}
		changeImg();
	}
	function changeImg(){      
		var imgSrc = $("#imgObj");
		var src = imgSrc.attr("src");  
		imgSrc.attr("src",chgUrl(src));     
	}     
	//时间戳     
	//为了使每次生成图片不一致，即不让浏览器读缓存，所以需要加上时间戳     
	function chgUrl(url){         
		var timestamp = (new Date()).valueOf();         
		urlurl = url.substring(0,17);         
		if((url.indexOf("&")>=0)){             
			urlurl = url + "&tamp=" + timestamp;         
		}else{             
			urlurl = url + "?timestamp=" + timestamp;         
		}         
		return urlurl;     
	} 
	
	function changeType(typeId,constant){
		$.ajax({
			url :"<%=request.getContextPath() %>/ext/information/gethLists", //要访问的后台地址
		    data: "site_id=yblsite01&toHome=1&pageSize=14&type_id="+typeId, //要发送的数据
		    type : 'POST', //使用get方法访问后台
		    dataType : 'json', //返回json格式的数据
		    success : function(data){
	   			var rows = data.recordList; 
	   			var aa = "<ul >";
		    	$.each(rows, function(i, n){
		    		var title=n.title;
		    		if(title.length>11){
		    			title = title.substr(0,10)+"...";
		    		}
		    		aa = aa+"<li><a style='float:left' href='xxzs?inforId="+n.id+"'>"+title+"</a><span style='float:right'>"+(new Date(n.createtime)).format("yyyy-MM-dd")+"</span></li>";
		        }); 
				$("#"+constant).html(aa+"</ul>");
		    }
		});	
	}
	
	function editContent(){
		$("#content_div").toggle();
		$("#informationformedit").toggle();
		$("#saveEditB").toggle();
	}
		
	function updateContent(){
		var options = {
			type: 'POST',
			async: false,
			success: function(msg) {
				if(msg=="codenull"){
					alert("验证码不得为空");
				}else if(msg=="failure"){
					alert("验证码不正确，请重新出入");
					$("veryCode").attr("value","");
				}else{
					alert("信息修改成功");
					document.location.reload();
				}
			}
		}
		$('#informationformedit').ajaxSubmit(options);
		var imgSrc = $("#imgObjedit");
		var src = imgSrc.attr("src");  
		imgSrc.attr("src",chgUrl(src));    
	}
</script>
</head>

<body>
<input type="hidden" name="site_id" value="yblsite01"/>
<%@ include file="header.jsp" %>
<div class="position">您的位置：首页 > 信息展示</div>

<div class="bbs">
	<div class="bbsl left">
    	<div class="bbs_text">
       	  <h3 id="title_div"></h3>
            <span id="name_time"></span>&nbsp;&nbsp;<a href="#" id = "saveEditB1" onclick = "editContent();" class="orange" style="font-size:12px;display:none">[编辑]</a>
            <a href="#" id = "saveEditB" onclick = "updateContent();" class="orange" style="font-size:12px;display:none">[保存]</a>
            <br  />
            <bdo id="content_div"></bdo>
            <form id="informationformedit" style="display:none" method="post" style="margin: 0" action="<%=path%>/ext/information/editcontent">
            <textarea id="eidt_editor_id" name="eidt_editor" style="width:650px;height:200px;"></textarea>
            <input id="veryCode0" name="veryCode0" type="text"/>        
            <input type="hidden" name="id" value="<%=inforId%>"/>       
			<img id="imgObjedit" style="vertical-align: middle;" src="<%=path %>/sys/getImg"/>  
            </form>
          	<p><br /><br />
            <div style="clear:both"></div>
        </div>
        <form name="frmxxzs" method="post" style="margin: 0" action="<%=path%>/ext/information/getReceipt?site_id=yblsite01&id=<%=inforId%>" id="frmxxzs">
		<div class="bbs_reply">
            <h3>回帖：</h3>
	          <table width="687" border="0" cellspacing="0" cellpadding="0" class="reply_list grid">
	            	<tbody>
						<tr class="template klId" >
						    <td width="96" rowspan="2" align="left" valign="top"><img src="<%=request.getContextPath()%>/site/${SiteAccessPath}/images/people.gif" width="81" height="90" /></td>
		       		    	<td width="94" height="20" align="left" class="klfoor" style="color:#999;"></td>
		            		<td width="298" height="20" align="left" class="klcreator" style="color:#ff6c00;"></td>
		            		<td width="199" height="20" align="right" class="kltime" style="color:#999;"></td>
						</tr>
					</tbody>
					<tfoot>
						<tr>
							<td style="border-right: none">
								<img id="loading"
									src="<%=imgPath %>/large-loading.gif" width="20px"
									class="hidden loading" />
							</td>
							<td colspan="3" style="border-left: none" class="txtRight">
								<span class="pagediv"></span>
							</td>
						</tr>
					</tfoot>
	          </table>
      </div>	
      </form>
      <div class="bbs_compile">
      	<div class="compile_title"><h2>快速回复</h2></div>
         <div class="compile_main">
        	<form id="informationform" method="post" style="margin: 0" action="<%=path%>/ext/information/send">
				<input type="hidden" disabled="disabled" name="title" id="titleaa" value="回复 1楼"/>
				<input type="hidden" name="pid" value="<%=inforId%>"/>
				<input type="hidden" name="site_id" value="yblsite01"/>
				<input type="hidden" name="type_id" id="type_id" value=""/>
				<input type="hidden" name="type_id2" id="type_id2" value=""/>
				<b class="left" >&nbsp;内容：</b>
				<textarea id="editor_id" name="content" style="width:650px;height:200px;"></textarea>
			    <script>
			    	KE.show({
						id : 'editor_id',
						items:['cut', 'copy', 'paste','|', 'textcolor','emoticons', 'link', 'unlink']
					});
			    </script>
			    <br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
			    <% 
			    	if (userId != null) {
			    %>
				<input type="button" onclick="save()" value="回复" />
		    	<input id="veryCode" name="veryCode" type="text"/>               
			    <img id="imgObj" style="vertical-align: middle;" src="<%=path %>/sys/getImg"/>               
			    <a href="javascript:changeImg()" >换一张</a>                             
			    <div id="info"></div> 
		    	<%
		    		} else {
		    	%>
				<input type="button" disabled="disabled" onclick="save()" value="回复" />
				您还没有登录，请先登录再回复信息！
				<%
					}
				%>
				<a name="BJ" id="BJ" ></a>
			</form>
		</div>
      </div>
    </div>
    <div class="bbsr right">
    	<div class="bbs_close">
       	  <div class="close_title"><h2 class="left">相关帖子</h2><img src="<%=request.getContextPath() %>/site/${SiteAccessPath}/images/title_more.gif" width="39" height="13" class="right"/></div>
          <div class="close_list" id="about_div">
          </div>
        </div>
        <div class="bbs_other">
        	<div class="other_title"><h2 class="left">其它帖子</h2><img src="<%=request.getContextPath() %>/site/${SiteAccessPath}/images/title_more.gif" width="39" height="13" class="right"/></div>
          	<div class="other_list" id="other_div">
          </div>
        </div>
    </div>
</div>
<div style="clear:both"></div>
<%@ include file="footer.jsp" %>
</body>
</html>






